<?php

if (!defined("EXPONENT")) exit("");
	$music = null;		
	if (isset($_GET['id'])) {
		$music = $db->selectObject('musics', 'id='.intval($_GET['id']));
	}
	//print_r($music);
	if ($music) {
	  // 9/5/2009: immanuel192 fix error: in table musics, location-data is not availible, how can you check permission?
    $album=$db->selectObject("album","id = {$music->album_id}");   
		$loc = unserialize($album->location_data);
		if (exponent_permissions_check("manage",$loc)) {
			// high quality
			$file = $db->selectObject('file','id='.$music->high_quality);
			if ($file)
			 {
			 	file::delete($file);
				$db->delete('file','id='.$file->id);
			 }
			/* for demo
			$file = $db->selectObject('file','id='.$music->demo);
			if ($file)
			 {
			 	file::delete($file);
				$db->delete('file','id='.$file->id);
			 }
			// for sheet musics
			$file = $db->selectObject('file','id='.$music->sheet_music);
			if ($file)
			 {
			 	file::delete($file);
				$db->delete('file','id='.$file->id);
			 }
			// for sound trackmix
			$file = $db->selectObject('file','id='.$music->sound_trackmix);
			if ($file)
			 {
			 	file::delete($file);
				$db->delete('file','id='.$file->id);
			 }
			*/
			// for this item
			$db->delete('musics','id='.$music->id);
			exponent_flow_redirect();
		} else {
			echo SITE_403_HTML;
		}
	} else {
		echo SITE_404_HTML;
	}

?>
